package com.hzit.vo;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class Student implements BeanNameAware, BeanFactoryAware, ApplicationContextAware,
		InitializingBean, DisposableBean {
	private String name;
	public Student() {
		System.out.println("Student 构造方法执行 ");
	}

	@Override
	public void setBeanName(String name) {
		System.out.println("Student#setBeanName() 执行");
	}

	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		System.out.println("Student#setBeanFactory() 执行");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		System.out.println("Student#setApplicationContext() 执行");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("Student#afterPropertiesSet() 执行");
	}

	@Override
	public void destroy() throws Exception {
		System.out.println("Student#destroy() 销毁方法执行");
	}

	public void setName(String name) {
		this.name = name;
		System.out.println("Student#setStudentName() 执行");
	}

	// 默认初始化方法
	private void myPostConstruct() {
		System.out.println("Student#myPostConstruct() 执行");
	}

	// 自定义初始化方法
	@PostConstruct
	public void springPostConstruct() {
		System.out.println("@PostConstruct 自定义初始化方法执行");
	}

	//默认销毁方法
	private void myPreDestroy() {
		System.out.println("Student#myPreDestroy 执行");
	}

	//自定义销毁方法
	@PreDestroy
	public void springPreDestroy() {
		System.out.println("@PreDestroy自定义销毁方法执行");
	}
}


